<?php
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.0
 */


get_header(); ?>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3.3&sensor=false"></script>
<script type="text/javascript" src="/wp-content/themes/rcd/js/markermanager.js"></script>
<script type="text/javascript" src="/wp-content/themes/rcd/js/StyledMarker.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="/wp-content/themes/rcd/js/jquery.metadata.js"></script>
<script type="text/javascript" src="/wp-content/themes/rcd/js/jquery.jmapping.js"></script>

<style>
#map {
	width: 600px;
	height: 460px;
	float: left;
}
</style>

		<div id="container">
			<div id="content" role="main">
		<div id="map-side-bar">
			<?php
			/* Run the loop to output the posts.
			 * If you want to overload this in a child theme then include a file
			 * called loop-index.php and that will be used instead.
			 */
//			 get_template_part( 'loop', 'index' );

the_category();
//$the_query = new WP_Query( );
$the_query = new WP_Query( array( 'meta_key' => 'todo:status', 'meta_value' => 'COMPLETED', 'meta_compare' => '!=' ,'category_name' => 'cortes-y-desvios')  );
while ( $the_query->have_posts() ) : $the_query->the_post();
	$lat = get_post_meta($id, '_wp_geo_latitude', true);
	if (!$lat) {
		$lat = get_post_meta($id, 'Latitud', true);
	}
	if (!$lat) {
		$lat = get_post_meta($id, '_geotag_lat', true);
	}
	$lon = get_post_meta($id, '_wp_geo_longitude', true);
	if (!$lon) {
		$lon = get_post_meta($id, 'Longitud', true);
	}
	if (!$lon) {
		$lon = get_post_meta($id, '_geotag_lon', true);
	}
	if ($lat && $lon) {
		echo '<div class="map-location" data-jmapping="{id: '.$id.', point: {lat: '.$lat.', lng: '.$lon.'}}">';
		echo '<a href="#" class="map-link">';
	} else {
		echo '<div>';
	}
	the_title();
	if ($lat && $lon) {
		echo '</a>';
	}
	if ($lat && $lon) {
		echo '<div class="info-box"><p>';
		the_content();
		echo '</p></div>';
	}
	echo '</div>';
endwhile;
			?>
		                                            </div>
		<div id="map"></div>
			</div><!-- #content -->
			<?php get_sidebar(); ?>
		</div><!-- #container -->

<script>
$(document).ready(function(){
  $('#map').jMapping();
  });
</script>
<?php get_footer(); ?>
